<template>
  <div class="wa-card wa-member-rote" ref="chartContentRef">
  </div>
</template>

<script setup>
import * as echarts from 'echarts';
import {onMounted, ref, defineProps} from "vue";

const props = defineProps({
  data: {
    type: Array,
    required: true,
  },

  title: {
    type: String,
    required: true
  }
})
const chartContentRef = ref(null)
onMounted(() => {
  const myChart = echarts.init(chartContentRef.value);
  myChart.setOption({
    title: {
      text: props.title,
      left: 'center'
    },
    tooltip: {
      trigger: 'item'
    },
    legend: {
      orient: 'vertical',
      left: 'left'
    }
  });
  const timer = setInterval(() => {
    if (props.data) {
      clearInterval(timer)
      myChart.setOption({
        series: [
          {
            type: 'pie',
            radius: '50%',
            data: props.data,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)'
              }
            }
          }
        ]
      })
    }
  }, 500)
})


</script>

<style lang="less" scoped>
.wa-member-rote {
  height: 400px;
  margin-right: 20px;

}
</style>